import Vue from 'vue'
import Router from 'vue-router'
import index from '@/components/index'
import myindex from '@/components/myindex'
import indexs from '@/components/indexs'
import myreg from '@/components/myreg'
import mylogin from '@/components/mylogin'
import mylogin_two from '@/components/mylogin_two'
import up_password from '@/components/up_password'
import user_show from '@/components/user_show'
import myhome from '@/components/myhome'
import authorize from '@/components/authorize'
import cate_show from '@/components/cate_show'
import showcate from '@/components/showcate'
import add_course from '@/components/add_course'
import courseadd from '@/components/courseadd'
import courselist from '@/components/courselist'
import details from '@/components/details'
import coursedetail from '@/components/coursedetail'
import login from '@/components/usergoods/login'
import goods from '@/components/usergoods/goods'
import test1 from '@/components/work1/test1'
import ant_reg from '@/components/work1/ant_reg'
import ant_index from '@/components/work1/ant_index'
import ant_admin from '@/components/work1/ant_admin'
import alter from '@/components/work1/alter'
import ant_details from '@/components/work1/ant_details'
import putuser from '@/components/work1/putuser'
import permission from '@/components/work1/permission'
import mylogin_three from '@/components/work1/mylogin_three'
import work_order from '@/components/work1/work_order'
import form from '@/components/work1/form'
import work_admin from '@/components/work1/work_admin'
import cate_detail from '@/components/work1/cate_detail'
import mywork from '@/components/work1/myworkorder'
import check_pending from '@/components/work1/check_pending'
import message from '@/components/work1/message'


Vue.use(Router)

var routes = [
        {
          path:'/',
          name:'index',
          component:index
        },
        {
          path:'/myindex',
          name:'myindex',
          component:myindex
        },
        {
          path:'/indexs',
          name:'indexs',
          component:indexs
        },
        // {
        //   path:'/myreg',
        //   name:'myreg',
        //   component:myreg
        // },
        {
          path:'/mylogin',
          name:'mylogin',
          component:mylogin
        },
        {
          path:'/mylogin_two',
          name:'mylogin_two',
          component:mylogin_two
        },
        {
          path:'/up_password',
          name:'up_password',
          component:up_password
        },
        {
          path:'/user_show',
          name:'user_show',
          component:user_show
        },
        {
          path:'/myhome',
          name:'myhome',
          component:myhome,
          beforeEnter: (to, from, next) => {
            // to  去哪里
            // from  来自哪里
            // next  下一步
            if (localStorage.getItem('username')){
              console.log("已经登录")
              next()
            }else{
              next('/mylogin_two')
            }
          }
        },
        {
          path:'/auth',
          name:'authoeize',
          component:authorize
        },
        {
          path:'/cate_show',
          name:'cate_show',
          component:cate_show
        },
        {
          path:'/showcate',
          name:'showcate',
          component:showcate
        },
        {
          path:'/add_course',
          name:'add_course',
          component:add_course
        },
        {
          path:'/courseadd',
          name:'courseadd',
          component:courseadd
        },
        {
          path:'/courselist',
          name:'courselist',
          component:courselist
        },
        {
          path:'/details',
          name:'details',
          component:details
        },
        {
          path:'/coursedetail',
          name:'coursedetail',
          component:coursedetail
        },
        {
          path:'/login',
          name:'login',
          component:login
        },
        {
          path:'/goods',
          name:'goods',
          component:goods
        },
        {
          path:'/test1',
          name:'test1',
          component:test1
        },
        {
          path:'/ant_reg',
          name:'ant_reg',
          component:ant_reg
        },
        {
          path:'/ant_index',
          name:'ant_index',
          component:ant_index,
          children:[
            {
              path:'/ant_admin',
              name:'ant_admin',
              component:ant_admin
            },
            {
              path:'/ant_details',
              name:'ant_details',
              component:ant_details
            },
            {
              path:'/myreg',
              name:'myreg',
              component:myreg
            },
            {
              path:'/alter',
              name:'alter',
              component:alter
            },
            {
              path:'/permission',
              name:'permission',
              component:permission
            },
            {
              path:'/work_order',
              name:'work_order',
              component:work_order
            },
            {
              path:'/form',
              name:'form',
              component:form
            },
            {
              path:'/work_admin',
              name:'work_admin',
              component:work_admin
            },
            {
              path:'/cate_detail',
              name:'cate_detail',
              component:cate_detail
            },
            {
              path:'/mywork',
              name:'mywork',
              component:mywork
            },
            {
              path:'/check_pending',
              name:'check_pending',
              component:check_pending
            },
            {
              path:'/message',
              name:'message',
              component:message
            },
          ]
        },
        {
          path:'/putuser',
          name:'putuser',
          component:putuser
        },
        {
          path:'/mylogin3',
          name:'mylogin_three',
          component:mylogin_three
        },
        
        
]

export default new Router({
  routes:routes,
  mode:'history'   /*hash*/
})


